//
//  DescribeView.m
//  Happy Kitchen
//
//  Created by 冫柒Yun on 15/3/13.
//  Copyright (c) 2015年 mac_chen. All rights reserved.
//

#import "DescribeView.h"

@implementation DescribeView

- (instancetype)initWithFrame:(CGRect)frame diseaseDescribe:(NSString *)describe
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews:describe];
    }
    return self;
}

// 布局视图
- (void)createSubviews:(NSString *)describe
{
    
    // 描述的imageView
    UIImageView *headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 90)];
    headImageView.backgroundColor = [UIColor redColor];
    headImageView.userInteractionEnabled = YES;
    
    // 在imageView添加textlabel
    UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, self.frame.size.width - 40, headImageView.frame.size.height - 20)];
    textLabel.backgroundColor = [UIColor whiteColor];
    textLabel.text = describe;
    textLabel.numberOfLines = 0;
    textLabel.font = [UIFont systemFontOfSize:15];
    [headImageView addSubview:textLabel];
    
    // 在imageview上添加label
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(textLabel.frame.origin.x + textLabel.frame.size.width, textLabel.frame.origin.y, 20, textLabel.frame.size.height)];
    label.text = @"小知识";
    label.textColor = [UIColor redColor];
    label.font = [UIFont systemFontOfSize:18];
    label.numberOfLines = 0;
    label.backgroundColor = [UIColor purpleColor];
    [headImageView addSubview:label];
    
    
    
    // 添加轻拍手势
    UITapGestureRecognizer *headTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headTapAction:)];
    [headImageView addGestureRecognizer:headTap];
    [self addSubview:headImageView];
    
}
// 轻拍手势触发方法
- (void)headTapAction:(UITapGestureRecognizer *)tap
{
    [self.myDelegate modalTextDetailView];
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
